#include "wxsdirpickerctrl.h"
#include <wx/filepicker.h>

namespace {
  wxsRegisterItem<wxsDirPickerCtrl> Reg( _T( "DirPickerCtrl" ), _T( "目录控件" ), wxsTWidget, _T( "对话框" ), 120 );
  WXS_ST_BEGIN( wxsDirPickerCtrlStyles, _T( "wxDIRP_DIR_MUST_EXIST" ) )
  WXS_ST_CATEGORY( "wxDirPickerCtrl" )
  WXS_ST( wxDIRP_CHANGE_DIR )
  WXS_ST( wxDIRP_DIR_MUST_EXIST )
  WXS_ST( wxDIRP_USE_TEXTCTRL )
  WXS_ST_END()
  WXS_EV_BEGIN( wxsDirPickerCtrlEvents )
  WXS_EVI( EVT_DIRPICKER_CHANGED, wxEVT_COMMAND_DIRPICKER_CHANGED, wxFileDirPickerEvent, DirChanged )
  WXS_EV_END()
}

wxsDirPickerCtrl::wxsDirPickerCtrl( wxsItemResData* Data ):
  wxsWidget(
    Data,
    &Reg.Info,
    wxsDirPickerCtrlEvents,
    wxsDirPickerCtrlStyles ),
  m_sMessage( wxDirSelectorPromptStr ),
  m_sPath( wxEmptyString ) {}

void wxsDirPickerCtrl::OnBuildCreatingCode() {
  switch( GetLanguage() ) {
    case wxsCPP: {
      AddHeader( _T( "<wx/filepicker.h>" ), GetInfo().ClassName, 0 );
      Codef( _T( "%C(%W, %I, %n, %t, %P, %S, %T, %V, %N);\n" ), m_sPath.wx_str(), m_sMessage.wx_str() );
      BuildSetupWindowCode();
      return;
    }
    case wxsUnknownLanguage:
    default: {
      wxsCodeMarks::Unknown( _T( "wxsDirPickerCtrl::OnBuildCreatingCode" ), GetLanguage() );
    }
  }
}


wxObject* wxsDirPickerCtrl::OnBuildPreview( wxWindow* Parent, long Flags ) {
  wxDirPickerCtrl* Preview;
  Preview = new wxDirPickerCtrl( Parent, GetId(), m_sPath, m_sMessage, Pos( Parent ), Size( Parent ), Style() );
  return SetupWindow( Preview, Flags );
}


void wxsDirPickerCtrl::OnEnumWidgetProperties( M_Code_unused long Flags ) {
  WXS_SHORT_STRING( wxsDirPickerCtrl, m_sMessage, _T( "Message" ), _T( "message" ), wxDirSelectorPromptStr, false )
  WXS_SHORT_STRING( wxsDirPickerCtrl, m_sPath, _T( "Path" ), _T( "path" ), wxEmptyString, false )
}
